package indi.kane.simpleproject.vo;

public class ResultVo {
    public final static String SUCCESS = "成功";
    public final static String SUCCESS_CODE="1";
    public final static String FAILED = "失败";
    public final static String FAILED_CODE = "0";
    public final static String FAILED_EXCEPTION_CODE = "-1";


    private String code;
    private Object data;
    private String msg;

    public ResultVo() {
    }

    public ResultVo(String code, Object data, String msg) {
        this.code = code;
        this.data = data;
        this.msg = msg;
    }

    /**
     * 成功响应
     *
     * @param data 成功数据
     * @return
     */
    public static ResultVo success(Object data) {
        return new ResultVo(SUCCESS_CODE, data, SUCCESS);
    }

    /**
     * 成功响应
     *
     * @param msg  成功信息
     * @return
     */
    public static ResultVo success(String msg) {
        return new ResultVo(SUCCESS_CODE, null, msg);
    }

    /**
     * 响应失败
     * @param msg 错误信息
     * @return
     */
    public static ResultVo failed(String msg) {
        return new ResultVo(FAILED_CODE, FAILED, msg);
    }

    /**
     * 响应失败
     * @param msg 错误信息
     * @return
     */
    public static ResultVo failed_exception(String msg) {
        return new ResultVo(FAILED_EXCEPTION_CODE, null, msg);
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
